/*************************************************************************
	> File Name: 008.二分查找实现sqrt函数.c
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 三  8/25 11:37:54 2021
 ************************************************************************/

#include <stdio.h>
#include <math.h>

double func(double x) {
    return x * x;
}

//二分查找实现sqrt函数，sqrt查找的是连续的区间，而原本的二分查找结果是离散的
double binary_search(double (*func)(double), double x) {
    double head = 0, tail = x / 2.0, mid = 0;
    #define EPSL 1e-6
    while (fabs(func(mid) - x) > EPSL) {
        mid = (head + tail) / 2.0;
        if (func(mid) < x) head = mid + 1;
        else tail = mid - 1;
    }
    #undef EPSL
    return mid;
}

int main() {
    double n;
    while (~scanf("%lf", &n)) {
        double x = binary_search(func, n);
        printf("%g * %g = %g\n", x, x, n);
    }
    return 0;
}
